/*
 * fastaAlgParam.cpp
 *
 *  Created on: 2011-10-23
 *      Author: pawel
 */
#include"fastaAlgParam.h"
#include"fastaGraph.h"
int diagonal::cntCompare(const void *ptrA,const void *ptrB){
	diagonal *dPtrA,*dPtrB;
	dPtrA = (diagonal*)ptrA;
	dPtrB = (diagonal*)ptrB;
	if(dPtrA->count < dPtrB->count)return 1;
	if(dPtrA->count > dPtrB->count)return -1;
	return 0;

}
int diagonal::diagNumCompare(const void *ptrA,const void *ptrB){
	diagonal *dPtrA,*dPtrB;
	dPtrA = (diagonal*)ptrA;
	dPtrB = (diagonal*)ptrB;
	if(dPtrA->diagNum > dPtrB->diagNum)return 1;
	if(dPtrA->diagNum < dPtrB->diagNum)return -1;
	return 0;
}
int diagonal::bestFragmentBeginCompare(const void *ptrA,const void *ptrB){
	diagonal *dPtrA,*dPtrB;
	dPtrA = (diagonal*)ptrA;
	dPtrB = (diagonal*)ptrB;
	if(dPtrA->bestFragment.begin > dPtrB->bestFragment.begin)return 1;
	if(dPtrA->bestFragment.begin < dPtrB->bestFragment.begin)return -1;
	return 0;
}

matrixPoint diagonal::diagToBegPoint(diagonal &diag){
	matrixPoint point;
	point.i =0;
	point.j=0;
	if(diag.diagNum > 0){
		point.j = (size_t)diag.diagNum;
	}
	else if(diag.diagNum < 0){
		point.i = (size_t)(-diag.diagNum);
	}

	point.i += diag.bestFragment.begin;
	point.j += diag.bestFragment.begin;
	return point;
}


matrixPoint diagonal::diagToEndPoint(diagonal &diag){
	matrixPoint point;
	point.i =0;
	point.j=0;
	if(diag.diagNum > 0){
		point.j = (size_t)diag.diagNum;
	}
	else if(diag.diagNum < 0){
		point.i = (size_t)(-diag.diagNum);
	}

	point.i += diag.bestFragment.end;
	point.j += diag.bestFragment.end;
	return point;
}
